home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / interapplication comm / moreappleevents / objecthelpers.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-23  |  11.2 KB  |  347 lines

  1. /*
  2.     File:        ObjectHelpers.h
  3.  
  4.     Contains:    Functions to help you when you are working with Apple event objects.
  5.  
  6.     Written by: Andy Bachorski    
  7.  
  8.     Copyright:    Copyright © 1996-1999 by Apple Computer, Inc., All Rights Reserved.
  9.  
  10.                 You may incorporate this Apple sample source code into your program(s) without
  11.                 restriction. This Apple sample source code has been provided "AS IS" and the
  12.                 responsibility for its operation is yours. You are not permitted to redistribute
  13.                 this Apple sample source code as "Apple sample source code" after having made
  14.                 changes. If you're going to re-distribute the source, we require that you make
  15.                 it clear in the source that the code was descended from Apple sample source
  16.                 code, but that you've made changes.
  17.  
  18.     Change History (most recent first):
  19.                 7/21/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  20.                 
  21.  
  22. */
  23.  
  24. #if PRAGMA_ONCE
  25.     #pragma once
  26. #endif
  27.  
  28. #ifndef _OBJECT_HELPERS_
  29. #define _OBJECT_HELPERS_
  30.  
  31.  
  32. // %%%%% need to change calls to object building function to pass a boolean
  33. // %%%%% parameter to control the disposal of descs passed in.
  34.  
  35. //******************************************************************************
  36. //    A private conditionals file to setup the build environment for this project.
  37.  
  38. #include "PrivateConditionals.h"
  39.  
  40.  
  41. //**********    Universal Headers        ****************************************
  42.  
  43. #include <AERegistry.h>
  44. #include <AEObjects.h>
  45. #include <AEPackObject.h>
  46. #include <Aliases.h>
  47. #include <Icons.h>
  48.  
  49.  
  50. //******************************************************************************
  51.  
  52. #ifdef __cplusplus
  53.     extern "C" {
  54. #endif
  55.  
  56. #if PRAGMA_IMPORT
  57.     #pragma import on
  58. #endif
  59.  
  60. #if PRAGMA_STRUCT_ALIGN
  61.     #pragma options align=mac68k
  62. #elif PRAGMA_STRUCT_PACKPUSH
  63.     #pragma pack(push, 2)
  64. #elif PRAGMA_STRUCT_PACK
  65.     #pragma pack(2)
  66. #endif
  67.  
  68.  
  69. //******************************************************************************
  70.  
  71. pascal    OSErr    OHAddAliasParameterFromFSS( const FSSpecPtr fssPtr,
  72.                                                 DescType keyword,
  73.                                                 AERecord *theRecordPtr );
  74. /*
  75.     Add a parameter of type typeAlias to an AERecord (or AppleEvent) using the provided FSSpec.
  76.  
  77.     fssPtr            input:    Pointer to the FSSpec to use.
  78.     keyword            input:    The key for the data to be added to the record.
  79.     theRecordPtr    input:    Pointer to the record (or event) to add the data to.
  80.     
  81.     RESULT CODES
  82.     ____________
  83.     noErr               0    No error    
  84.     paramErr         -50    The value of target or alias parameter, or of
  85.                             both, is NIL, or the alias record is corrupt
  86.     memFullErr        -108    Not enough room in heap zone    
  87. */
  88.  
  89. //******************************************************************************
  90.  
  91. pascal    OSErr    OHMakeAliasDescFromFSSpec( const FSSpecPtr fssPtr,
  92.                                                   AEDesc *aliasDescPtr );
  93. /*
  94.     Create and return an AEDesc of type typeAlias using the provided FSSpec.
  95.  
  96.     fssPtr            input:    Pointer to the FSSpec to use.
  97.     aliasDescPtr    input:    Pointer to null AEDesc.
  98.                     output:    an AEDesc of type typeAlias.
  99.     
  100.     RESULT CODES
  101.     ____________
  102.     noErr               0    No error    
  103.     paramErr         -50    The value of target or alias parameter, or of
  104.                             both, is NIL, or the alias record is corrupt
  105.     memFullErr        -108    Not enough room in heap zone    
  106. */
  107.  
  108. //******************************************************************************
  109.  
  110. pascal OSErr OHMakeAliasDesc( const AliasHandle aliasHandle,
  111.                                      AEDesc *aliasDescPtr );
  112. /*
  113.     Create and return an AEDesc of type typeAlias using the provided 
  114.     alias record.
  115.  
  116.     aliasHandle        input:    Handle to an alias record.
  117.     aliasDescPtr    input:    Pointer to null AEDesc.
  118.                     output:    an AEDesc of type typeAlias.
  119.     
  120.     RESULT CODES
  121.     ____________
  122.     noErr               0    No error    
  123.     memFullErr        -108    Not enough room in heap zone    
  124. */
  125.  
  126.  
  127. //******************************************************************************
  128.  
  129. pascal    OSErr    OHMakeAliasObjectFromFSSpec( const FSSpecPtr fssPtr,
  130.                                                     AEDesc *containerObjPtr,
  131.                                                     AEDesc *aliasObjectPtr );
  132. /*
  133.     Given an FSSpec, return an object descriptor containing an alias,
  134.     contained by containerObj.
  135.     
  136.     fssPtr            input:    Pointer to the FSSpec to use.
  137.     containerObjPtr    input:    Pointer to container object for object being created.
  138.     aliasObjectPtr    input:    Pointer to null AEDesc.
  139.                     output:    an alias object.
  140.     
  141.     RESULT CODES
  142.     ____________
  143.     noErr                    0    No error    
  144.     paramErr              -50    The value of target or alias parameter, or of
  145.                                 both, is NIL, or the alias record is corrupt
  146.     memFullErr             -108    Not enough room in heap zone    
  147.     errAECoercionFail     -1700    Data could not be coerced to the requested 
  148.                                 Apple event data type    
  149.     errAEWrongDataType    -1703    Wrong Apple event data type    
  150.     errAENotAEDesc        -1704    Not a valid descriptor record    
  151.     errAEBadListItem    -1705    Operation involving a list item failed    
  152. */
  153.  
  154. //******************************************************************************
  155.  
  156. pascal    OSErr    OHMakeAliasObject( const AliasHandle aliasHandle,
  157.                                           AEDesc *containerObjPtr,
  158.                                           AEDesc *aliasObjectPtr );
  159. /*
  160.     Given an AliasHandle, return an object descriptor containing an alias,
  161.     contained by containerObj.
  162.     
  163.     aliasHandle        input:    Handle to an alias record.
  164.     containerObjPtr    input:    Pointer to container object for object being created.
  165.     aliasObjectPtr    input:    Pointer to null AEDesc.
  166.                     output:    an alias object.
  167.     
  168.     RESULT CODES
  169.     ____________
  170.     noErr                    0    No error    
  171.     paramErr              -50    Error in parameter list
  172.     memFullErr             -108    Not enough room in heap zone    
  173.     errAECoercionFail     -1700    Data could not be coerced to the requested 
  174.                                 Apple event data type    
  175.     errAEWrongDataType    -1703    Wrong Apple event data type    
  176.     errAENotAEDesc        -1704    Not a valid descriptor record    
  177.     errAEBadListItem    -1705    Operation involving a list item failed    
  178. */
  179.  
  180. //******************************************************************************
  181.  
  182. pascal    OSErr    OHMakePropertyObject( const DescType propType,
  183.                                              AEDesc *containerObjPtr,
  184.                                              AEDesc *propertyObjPtr );
  185. /*
  186.     Given a property type, create an new object descriptor for that property,
  187.     contained by containerObj.
  188.     
  189.     propType        input:    Property type to use for object.
  190.     containerObjPtr    input:    Pointer to container object for object being created.
  191.     propertyObjPtr    input:    Pointer to null AEDesc.
  192.                     output:    A property object.
  193.     
  194.     RESULT CODES
  195.     ____________
  196.     noErr                    0    No error    
  197.     paramErr              -50    Error in parameter list
  198.     memFullErr             -108    Not enough room in heap zone    
  199.     errAECoercionFail     -1700    Data could not be coerced to the requested 
  200.                                 Apple event data type    
  201.     errAEWrongDataType    -1703    Wrong Apple event data type    
  202.     errAENotAEDesc        -1704    Not a valid descriptor record    
  203.     errAEBadListItem    -1705    Operation involving a list item failed    
  204. */
  205.  
  206. //******************************************************************************
  207. pascal    OSErr    OHMakeProcessObject( const ProcessSerialNumber *psnPtr,
  208.                                             AEDesc *containerObjPtr,
  209.                                             AEDesc *psnObjPtr );
  210. /*
  211.     Given a ProcessSerialNumber, create an new object descriptor for the PSN,
  212.     contained by containerObj.
  213.     
  214.     psnPtr            input:    ProcessSerialNumber to use for object.
  215.     containerObjPtr    input:    Pointer to container object for object being created.
  216.     psnObjPtr        input:    Pointer to null AEDesc.
  217.                     output:    A ProcessSerialNumber object.
  218.     
  219.     RESULT CODES
  220.     ____________
  221.     noErr                    0    No error    
  222.     paramErr              -50    Error in parameter list
  223.     memFullErr             -108    Not enough room in heap zone    
  224.     errAECoercionFail     -1700    Data could not be coerced to the requested 
  225.                                 Apple event data type    
  226.     errAEWrongDataType    -1703    Wrong Apple event data type    
  227.     errAENotAEDesc        -1704    Not a valid descriptor record    
  228.     errAEBadListItem    -1705    Operation involving a list item failed    
  229. */
  230.  
  231. //******************************************************************************
  232.  
  233. pascal    OSErr    OHMakeSelectionObject( const DescType selection,
  234.                                               AEDesc *containerObjPtr,
  235.                                               AEDesc *selectionObject );
  236. /*
  237.     Given selection type, create an new object descriptor for a selection,
  238.     contained by containerObj.
  239.     
  240.     selection        input:    Selection type to use for object.
  241.     containerObjPtr    input:    Pointer to container object for object being created.
  242.     selectionObject    input:    Pointer to null AEDesc.
  243.                     output:    A property object.
  244.     
  245.     RESULT CODES
  246.     ____________
  247.     noErr                    0    No error    
  248.     paramErr              -50    Error in parameter list
  249.     memFullErr             -108    Not enough room in heap zone    
  250.     errAECoercionFail     -1700    Data could not be coerced to the requested 
  251.                                 Apple event data type    
  252.     errAEWrongDataType    -1703    Wrong Apple event data type    
  253.     errAENotAEDesc        -1704    Not a valid descriptor record    
  254.     errAEBadListItem    -1705    Operation involving a list item failed    
  255. */
  256.  
  257. //******************************************************************************
  258. pascal    OSErr    OHMakeIconSuite( const AEDescList *iconFamilyRecPtr,
  259.                                         Handle *iconSuitePtr );
  260. /*
  261.     Make an icon suite containing the icons in an icon family record, as returned
  262.     by the Finder. Behaves simmilar to a call to GetIconSuite, i.e., a new icon
  263.     suite handle will be returned in iconSuitePtr.
  264.     
  265.     iconFamilyRecPtr    input:    The icon family to process.
  266.     iconSuitePtr        input:    Pointer to an icon suite handle variable
  267.                         output:    An icon suite containing the icons from the
  268.                                 icon family record.
  269.     
  270.     Result Codes
  271.     ____________
  272.     noErr                    0    No error    
  273.     paramErr              -50    The value of target or alias parameter, or of
  274.                                 both, is NIL, or the alias record is corrupt
  275.     memFullErr             -108    Not enough room in heap zone    
  276.     errAECoercionFail     -1700    Data could not be coerced to the requested 
  277.                                 Apple event data type    
  278. */
  279.  
  280. //******************************************************************************
  281.  
  282. pascal    OSErr    OHMakeIconFamilyRecord( const Handle iconSuite,
  283.                                          const IconSelectorValue iconSelector,
  284.                                                AEDescList *iconFamilyRecPtr );
  285. /*
  286.     Make an icon family record containing the icons specified in the
  287.     iconSelector parameter.
  288.     The iconSuite parameter should contain an icon suite, as returned by a
  289.     call to GetIconSuite.
  290.     
  291.     iconSuite            input:    The icon suite to build the record from.
  292.     iconSelector        input:    Which icons to include in the record.
  293.     iconFamilyRecPtr    input:    Pointer to null AEDesc.
  294.                         output:    An AERecord that's been coerced to an
  295.                                 icon family record.
  296.     
  297.     Result Codes
  298.     ____________
  299.     noErr                    0    No error    
  300.     paramErr              -50    The value of target or alias parameter, or of
  301.                                 both, is NIL, or the alias record is corrupt
  302.     memFullErr             -108    Not enough room in heap zone    
  303.     errAECoercionFail     -1700    Data could not be coerced to the requested 
  304.                                 Apple event data type    
  305. */
  306.  
  307. //******************************************************************************
  308.  
  309. pascal    OSErr    OHMakePositionList( const Point position,
  310.                                      AEDescList *posListPtr );
  311. /*
  312.     Make position list (a list containing two longs representin the x and y values
  313.     for the position of a Finder item).
  314.     
  315.     position            input:    A point specifying the position.
  316.     posListPtr            input:    Pointer to an AEList (contents will be lost, but not disposed).
  317.                         output:    A new AEList containing the x & y values for the position.
  318.     
  319.     Result Codes
  320.     ____________
  321.     noErr                    0    No error    
  322.     memFullErr             -108    Not enough room in heap zone    
  323. */
  324.  
  325. //******************************************************************************
  326.  
  327.  
  328. #if PRAGMA_STRUCT_ALIGN
  329.     #pragma options align=reset
  330. #elif PRAGMA_STRUCT_PACKPUSH
  331.     #pragma pack(pop)
  332. #elif PRAGMA_STRUCT_PACK
  333.     #pragma pack()
  334. #endif
  335.  
  336. #ifdef PRAGMA_IMPORT_OFF
  337. #pragma import off
  338. #elif PRAGMA_IMPORT
  339. #pragma import reset
  340. #endif
  341.  
  342. #ifdef __cplusplus
  343. }
  344. #endif
  345.  
  346. #endif// _OBJECT_HELPERS_
  347.